<template>
  <div class="m-menu">
    <dl @mouseleave="mouseleave" class="nav">
      <dt>全部分类</dt>
      <dd
        @mouseenter="enter"
        v-for="(item,key) in $store.state.home.menu"
        :key="key"
      >
        <i :class="item.type" />{{ item.name }}<span class="arrow" />
      </dd>
    </dl>
    <div
      v-if="kind"
      @mouseenter="sover"
      @mouseleave="sout"
      class="detail"
    >
      <template
        v-for="(item,i) in curdetail.child"
      >
        <h4 :key="i">
          {{ item.title }}
        </h4>
        <span
          v-for="v in item.child"
          :key="v"
        >{{ v }}</span>
      </template>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      kind: '',
      menu: []
    }
  },
  computed: {
    curdetail () {
      return this.$store.state.home.menu.filter(item => item.type === this.kind)[0]
    }
  },
  methods: {
    mouseleave () {
      this.timer = setTimeout(() => {
        this.kind = ''
      }, 150)
    },
    enter (e) {
      this.kind = e.target.querySelector('i').className
    },
    sover () {
      clearTimeout(this.timer)
    },
    sout () {
      this.kind = ''
    }
  }
}
</script>
<style lang="scss">

</style>
